import com.lmq.onjava.Rand;

import java.util.*;

public class testCollection {
    public static void testArrayList() {
        ArrayList<Integer> integers = new ArrayList<>();
        integers.add(12);
        Integer ones = integers.get(0);
        System.out.println(ones);
        System.out.println("size now is "+ integers.size());
    }

    public static void testArrayDeque() {
        ArrayDeque<Integer> integers = new ArrayDeque<>(new ArrayList<>(Arrays.asList(1,2,34,5,7,11)));
        System.out.println(integers.pollFirst());
        System.out.println(integers);
        System.out.println(integers.peek());
        System.out.println(integers.peekLast());
        System.out.println(integers.pollLast());
        System.out.println(integers);
        integers.addFirst(5);
        System.out.println(integers);
        integers.addLast(99);
        System.out.println(integers);

    }

    public static void testQueue() {
        Queue<Integer> queue = new LinkedList<>();
        Random rand = new Random(47);
        for (int i = 0; i < 10; i++)
            queue.offer(rand.nextInt(i + 10));

        while(queue.peek() != null)
            System.out.print(queue.remove() + " ");
        System.out.println();

        Queue<Character> qc = new LinkedList<>();
        for(char c : "Brontosaurus".toCharArray())
            qc.offer(c);

        while(qc.peek() != null)
            System.out.print(qc.remove() + " ");
        System.out.println();

    }


    public static void main(String[] args) {
//        testArrayList();

//        testArrayDeque();

        testQueue();

    }
}
